package com.contract.spirit.bean.entity

import android.text.TextUtils

/**
 * @author: witness
 * created: 2021/9/28
 * desc:
 */
data class OrderInfo(
    val id: String,
    val symbol: String,
    val side: String,
    val price: String,
    val quantity: String,
    val realizedPnl: String,
    val orderTime: String,
    val gainAmount: String,
    val btnTip: String,
    val status: Int
) {
    fun getStatusDesc(): String {
        if (status == 1) {
            return "获得赔付"
        } else if (status == 2) {
            return "赔付成功"
        }
        return ""
    }

    fun isSell(): Boolean {
        return "SELL".equals(side, ignoreCase = true)
    }

    fun isNegative(): Boolean {
        return !TextUtils.isEmpty(realizedPnl) && realizedPnl.contains("-")
    }

    fun getShowGainAmount(): String {
        return String.format("%s USDT", if (TextUtils.isEmpty(gainAmount)) "---" else gainAmount)
    }

    fun getShowGainBtnType(): Int {
        if (TextUtils.isEmpty(btnTip)) {
            return 1
        } else {
            if ("索要赔付" == btnTip) {
                return 2
            }
            return 3
        }
    }

}
